﻿using System.Xml.Linq;
using System;

namespace Lightray.Hattrick.ChppLib.EntityTypes
{
    public class Manager : EntityBase
    {
        #region Properties
        public string LoginName { get; private set; }
        public bool IsSupporter { get; private set; }
        public string Name { get; private set; }
        public DateTime LastLoginDate { get; private set; }
        #endregion

        private Manager() { } 

        //TODO: Change to internal
        public static Manager FromTeamXml(XElement managerNode)
        {
            HattrickXmlReader reader = new HattrickXmlReader(managerNode);
            return new Manager()
            {
                // TODO: change to consts
                ID = reader.ReadNumber("UserID"),
                IsSupporter = reader.ReadBoolean("HasSupporter"),
                LoginName = reader.ReadString("Loginname"),
                Name = reader.ReadString("Name"),                
                LastLoginDate = reader.ReadDate("LastLoginDate"),                
            };
        }

        public override string ToString()
        {
            return LoginName;
        }                           
    }
}

  
  